package com.fw;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.fw.service.UserService;

public class Main {
    public static void main(String[] args) {
        //加载ApplicationContext.xml,启动Spring容器
        ApplicationContext ac = new ClassPathXmlApplicationContext("ApplicationContext.xml");
        HelloService helloService=(HelloService)ac.getBean("helloService");
        System.out.println("====Spring测试=====");
        System.out.println(helloService.sayHello());
        System.out.println(helloService.sayHelloTo("Spring"));

        // 传统的方式
        HelloService helloService2=new HelloServiceImpl();

        UserService userService=(UserService)ac.getBean("userService");
        System.out.println("====Spring测试2=====");
        userService.registerUser("Test1024");
        List<String> users=userService.getAllUsers();
        for(String user:users){
            System.out.println(user);
        }
        
    }
}